package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Paper1;
import com.ruoyi.system.service.IPaper1Service;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 论文管理1Controller
 * 
 * @author ruoyi
 * @date 2024-12-09
 */
@Controller
@RequestMapping("/system/paper1")
public class Paper1Controller extends BaseController
{
    private String prefix = "system/paper1";

    @Autowired
    private IPaper1Service paper1Service;

    @RequiresPermissions("system:paper1:view")
    @GetMapping()
    public String paper1()
    {
        return prefix + "/paper1";
    }

    /**
     * 查询论文管理1列表
     */
    @RequiresPermissions("system:paper1:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(Paper1 paper1)
    {
        startPage();
        List<Paper1> list = paper1Service.selectPaper1List(paper1);
        return getDataTable(list);
    }

    /**
     * 导出论文管理1列表
     */
    @RequiresPermissions("system:paper1:export")
    @Log(title = "论文管理1", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(Paper1 paper1)
    {
        List<Paper1> list = paper1Service.selectPaper1List(paper1);
        ExcelUtil<Paper1> util = new ExcelUtil<Paper1>(Paper1.class);
        return util.exportExcel(list, "论文管理1数据");
    }

    /**
     * 新增论文管理1
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存论文管理1
     */
    @RequiresPermissions("system:paper1:add")
    @Log(title = "论文管理1", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(Paper1 paper1)
    {
        return toAjax(paper1Service.insertPaper1(paper1));
    }

    /**
     * 修改论文管理1
     */
    @RequiresPermissions("system:paper1:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        Paper1 paper1 = paper1Service.selectPaper1ById(id);
        mmap.put("paper1", paper1);
        return prefix + "/edit";
    }

    /**
     * 修改保存论文管理1
     */
    @RequiresPermissions("system:paper1:edit")
    @Log(title = "论文管理1", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(Paper1 paper1)
    {
        return toAjax(paper1Service.updatePaper1(paper1));
    }

    /**
     * 删除论文管理1
     */
    @RequiresPermissions("system:paper1:remove")
    @Log(title = "论文管理1", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(paper1Service.deletePaper1ByIds(ids));
    }
}
